
type dateFormatType = 'yyyy-mm-dd' | 'yyyy-mm-dd hh:mm:ss' | 'hh:mm:ss'
/**
 * 获取当前月份的天数
 * @param year 年份 默认当前年份
 * @param month 月份 默认当前月份
 * @returns 天数
 */
export const getDayNumByMonth = function (year?: number, month?: number) {
  const date = new Date()
  if (!year) year = date.getFullYear()
  if (!month) month = date.getMonth() + 1
  return new Date(year, month, 0).getDate()
}

/**
 * 获取今天的日期
 * @param inputFormat 格式 需要输出的格式
 * @returns 日期 
 */
export const formatCurrentTime = function (inputFormat: dateFormatType) {
  const currentDate = new Date();
  const year = String(currentDate.getFullYear())
  const month = String(currentDate.getMonth() + 1).padStart(2, '0');
  const day = String(currentDate.getDate()).padStart(2, '0');
  const hours = String(currentDate.getHours()).padStart(2, '0');
  const minutes = String(currentDate.getMinutes()).padStart(2, '0');
  const seconds = String(currentDate.getSeconds()).padStart(2, '0');

  let formattedTime = inputFormat.replace('yyyy', year)
    .replace('mm', month)
    .replace('dd', day)
    .replace('hh', hours)
    .replace('mm', minutes)
    .replace('ss', seconds);

  return formattedTime;
}

/**
 * 获取今天星期几
 */
export const getTodayWhatDay = function () {
  const daysOfWeek = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
  const currentDate = new Date();
  const dayIndex = currentDate.getDay();
  return daysOfWeek[dayIndex];
}